<?php require_once('../../Connections/cotiza.php'); ?>
<?php
$campo = $_GET['campo'];
$acc   = $_GET['acc'];
$label = $_GET['label'];
$clean = $_GET['clean'];
$tipo  = $_GET['tipo'];

mysql_select_db($database_cotiza, $cotiza);

if($acc == "search")
{
	$b = $_POST['busqueda'];
	$query = "SELECT * FROM tipo_prod_mstr WHERE tipo_id like '%$b%' or tipo_desc like '%$b%' ORDER BY tipo_id";
}
else
	$query = "SELECT * FROM tipo_prod_mstr ORDER BY tipo_id";
	
$resultados = mysql_query($query, $cotiza) or die(mysql_error());
$row = mysql_fetch_assoc($resultados);
$totalRows = mysql_num_rows($resultados);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>..:: Tipo de productos ::..</title>
<link href="../../main.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.default_title {
	color: #FFF;
}
-->
</style>
</head>

<body onload="document.form1.busqueda.focus();">
<form id="form1" name="form1" method="post" action="tipo_productos.php?tipo=<?php echo $tipo;?>&clean=<?php echo $clean;?>&label=<?php echo $label; ?>&campo=<?php echo $campo; ?>&acc=search">
  <table border="0" align="center">
    <tr>
      <td >B&uacute;squeda de Tipo producto:</td>
      <td ><input name="busqueda" class="default" size="20" autocomplete="off"/></td>
      <td ><input type="submit" value="Buscar" class="v8" /></td>
    </tr>
  </table>
</form>
<br />
<?php if($totalRows >0){?>
  <table border="1" align="center" cellpadding="2" cellspacing="0">
    <tr class="default_title">
      <td width="104" align="center" bgcolor="#0000CC">C&oacute;digo</td>
      <td width="306" align="center" bgcolor="#0000CC">Descripci&oacute;n</td>
    </tr>
    <?php do { ?>
    <tr>
      <td><a href="javascript:window.opener.document.getElementById('<?php echo $campo; ?>').value= '<?php echo $row['tipo_id']; ?>'; <?php 
	  		if($label <> "") 
				echo "window.opener.document.getElementById('$label').innerHTML = '".$row['tipo_desc']."';"; 
			if($clean == 1)
			{
				echo "window.opener.document.getElementById('detail-familia').innerHTML = '';";
				echo "window.opener.document.getElementById('desc-material').innerHTML = '';";
				echo "window.opener.document.getElementById('material').value = '';";
			}
			if($tipo == 1)
			{
				echo "window.opener.document.getElementById('tipo_producto').value = '".$row['tipo_corto']."';";
				echo "window.opener.esconde_largo();";
			}
			?>window.opener.document.getElementById('<?php echo $campo; ?>').focus();window.close();"> <?php echo $row['tipo_id']; ?></a>&nbsp;</td>
      <td> <?php echo $row['tipo_desc']; ?>&nbsp;</td>
    </tr>
      <?php } while ($row = mysql_fetch_assoc($resultados)); ?>
  </table>
<?php }?>
</body>
</html>
<?php 
mysql_close($cotiza);
?>